set.seed(1)
x<-seq(0,10,length.out=1000)
y<-dunif(x,0,1)
plot(x,y,col="red",xlim=c(0,10),ylim=c(0,1.2),type='l',xaxs="i", yaxs="i",ylab='density',xlab='',main="The Uniform Density Distribution")
lines(x,dunif(x,0,0.5),col="green")
lines(x,dunif(x,0,2),col="blue")
lines(x,dunif(x,-2,1),col="orange")
lines(x,dunif(x,2,4),col="purple")
legend("topright",legend=paste("m=",c(0,0,0,-2,4)," sd=", c(1,0.5,2,1,2)), lwd=1, col=c("red", "green","blue","orange","purple"))

set.seed(1)
x<-seq(0,10,length.out=1000)
y<-punif(x,0,1)
plot(x,y,col="red",xlim=c(0,10),ylim=c(0,1.2),type='l',xaxs="i", yaxs="i",ylab='F(x)',xlab='',main="The Uniform Cumulative Distribution Function")
lines(x,punif(x,0,0.5),col="green")
lines(x,punif(x,0,2),col="blue")
lines(x,punif(x,-2,1),col="orange")
legend("bottomright",legend=paste("m=",c(0,0,0,-2)," sd=", c(1,0.5,2,1)), lwd=1, col=c("red", "green","blue","orange","purple"))

set.seed(1)
S<-runif(1000)
ks.test(S, "punif")    


set.seed(1)
x <- seq(-5,5,length.out=100)
y <- dnorm(x,0,1)
plot(x,y,col="red",xlim=c(-5,5),ylim=c(0,1),type='l',xaxs="i", yaxs="i",ylab='density',xlab='',main="The Normal Density Distribution")
lines(x,dnorm(x,0,0.5),col="green")
lines(x,dnorm(x,0,2),col="blue")
lines(x,dnorm(x,-2,1),col="orange")
legend("topright",legend=paste("m=",c(0,0,0,-2)," sd=", c(1,0.5,2,1)), lwd=1, col=c("red", "green","blue","orange"))

set.seed(1)
x <- seq(-5,5,length.out=100)
y <- pnorm(x,0,1)
plot(x,y,col="red",xlim=c(-5,5),ylim=c(0,1),type='l',xaxs="i", yaxs="i",ylab='F(x)',xlab='',main="The Normal Cumulative Distribution")
lines(x,pnorm(x,0,0.5),col="green")
lines(x,pnorm(x,0,2),col="blue")
lines(x,pnorm(x,-2,1),col="orange")
legend("bottomright",legend=paste("m=",c(0,0,0,-2)," sd=", c(1,0.5,2,1)), lwd=1,col=c("red", "green","blue","orange"))

set.seed(1)
S<-rnorm(1000)
shapiro.test(S)

set.seed(1)
S<-rnorm(1000)
ks.test(S, "pnorm") 


set.seed(1)
x<-seq(-1,2,length.out=100)
y<-dexp(x,0.5)
plot(x,y,col="red",xlim=c(0,2),ylim=c(0,5),type='l',xaxs="i", yaxs="i",ylab='density',xlab='',main="The Exponential Density Distribution")
lines(x,dexp(x,1),col="green")
lines(x,dexp(x,2),col="blue")
lines(x,dexp(x,5),col="orange")
legend("topright",legend=paste("rate=",c(.5, 1, 2,5)), lwd=1,col=c("red", "green","blue","orange"))

set.seed(1)
x<-seq(-1,2,length.out=100)
y<-pexp(x,0.5)
plot(x,y,col="red",xlim=c(0,2),ylim=c(0,1),type='l',xaxs="i", yaxs="i",ylab='F(x)',xlab='',main="The Exponential Cumulative Distribution Function")
lines(x,pexp(x,1),col="green")
lines(x,pexp(x,2),col="blue")
lines(x,pexp(x,5),col="orange")
legend("bottomright",legend=paste("rate=",c(.5, 1, 2,5)), lwd=1, col=c("red", "green","blue","orange"))

set.seed(1)
S<-rexp(1000)
ks.test(S, "pexp")      


set.seed(1)
x<-seq(0,10,length.out=100)
y<-dgamma(x,1,2)
plot(x,y,col="red",xlim=c(0,10),ylim=c(0,2),type='l',xaxs="i", yaxs="i",ylab='density',xlab='',main="The Gamma Density Distribution")
lines(x,dgamma(x,2,2),col="green")
lines(x,dgamma(x,3,2),col="blue")
lines(x,dgamma(x,5,1),col="orange")
lines(x,dgamma(x,9,1),col="black")
legend("topright",legend=paste("shape=",c(1,2,3,5,9)," rate=", c(2,2,2,1,1)), lwd=1, col=c("red", "green","blue","orange","black"))

set.seed(1)
x<-seq(0,10,length.out=100)
y<-pgamma(x,1,2)
plot(x,y,col="red",xlim=c(0,10),ylim=c(0,1),type='l',xaxs="i", yaxs="i",ylab='F(x)',xlab='',main="The Gamma Cumulative Distribution Function")
lines(x,pgamma(x,2,2),col="green")
lines(x,pgamma(x,3,2),col="blue")
lines(x,pgamma(x,5,1),col="orange")
lines(x,pgamma(x,9,1),col="black")
legend("bottomright",legend=paste("shape=",c(1,2,3,5,9)," rate=", c(2,2,2,1,1)), lwd=1, col=c("red", "green","blue","orange","black"))

set.seed(1)
S<-rgamma(1000,1)
ks.test(S, "pgamma", 1)  
ks.test(S, "pgamma", 2)          


set.seed(1)
x<- seq(0, 2.5, length.out=1000)
y<- dweibull(x, 0.5)
plot(x, y, type="l", col="blue",xlim=c(0, 2.5),ylim=c(0, 6),xaxs="i", yaxs="i",ylab='density',xlab='',main="The Weibull Density Distribution")
lines(x, dweibull(x, 1), type="l", col="red")
lines(x, dweibull(x, 1.5), type="l", col="magenta")
lines(x, dweibull(x, 5), type="l", col="green")
lines(x, dweibull(x, 15), type="l", col="purple")
legend("topright", legend=paste("shape =", c(.5, 1, 1.5, 5, 15)), lwd=1,col=c("blue", "red", "magenta", "green","purple"))

set.seed(1)
x<- seq(0, 2.5, length.out=1000)
y<- pweibull(x, 0.5)
plot(x, y, type="l", col="blue",xlim=c(0, 2.5),ylim=c(0, 1.2),xaxs="i", yaxs="i",ylab='F(x)',xlab='',main="The Weibull Cumulative Distribution Function")
lines(x, pweibull(x, 1), type="l", col="red")
lines(x, pweibull(x, 1.5), type="l", col="magenta")
lines(x, pweibull(x, 5), type="l", col="green")
lines(x, pweibull(x, 15), type="l", col="purple")
legend("bottomright", legend=paste("shape =", c(.5, 1, 1.5, 5, 15)), lwd=1, col=c("blue", "red", "magenta", "green","purple"))

set.seed(1)
S<-rweibull(1000,1)
ks.test(S, "pweibull",1) 


set.seed(1)
x<-seq(0,10,length.out=1000)
y<-dchisq(x,1)
plot(x,y,col="red",xlim=c(0,5),ylim=c(0,2),type='l',xaxs="i", yaxs="i",ylab='density',xlab='',main="The Chisq Density Distribution")
lines(x,dchisq(x,2),col="green")
lines(x,dchisq(x,3),col="blue")
lines(x,dchisq(x,10),col="orange")
legend("topright",legend=paste("df=",c(1,2,3,10)), lwd=1, col=c("red", "green","blue","orange"))

set.seed(1)
x<-seq(0,10,length.out=1000)
y<-pchisq(x,1)
plot(x,y,col="red",xlim=c(0,10),ylim=c(0,1),type='l',xaxs="i", yaxs="i",ylab='F(x)',xlab='',main="The Chisq Cumulative Distribution Function")
lines(x,pchisq(x,2),col="green")
lines(x,pchisq(x,3),col="blue")
lines(x,pchisq(x,10),col="orange")
legend("topleft",legend=paste("df=",c(1,2,3,10)), lwd=1, col=c("red", "green","blue","orange"))

set.seed(1)
S<-rchisq(1000,1)
ks.test(S, "pchisq",1) 



set.seed(1)
x<-seq(0,5,length.out=1000)
y<-df(x,1,1,0)
plot(x,y,col="red",xlim=c(0,5),ylim=c(0,1),type='l',xaxs="i", yaxs="i",ylab='density',xlab='',main="The F Density Distribution")
lines(x,df(x,1,1,2),col="green")
lines(x,df(x,2,2,2),col="blue")
lines(x,df(x,2,4,4),col="orange")
legend("topright",legend=paste("df1=",c(1,1,2,2),"df2=",c(1,1,2,4)," ncp=", c(0,2,2,4)), lwd=1, col=c("red", "green","blue","orange"))

set.seed(1)
x<-seq(0,5,length.out=1000)
y<-df(x,1,1,0)
plot(x,y,col="red",xlim=c(0,5),ylim=c(0,1),type='l',xaxs="i", yaxs="i",ylab='F(x)',xlab='',main="The F Cumulative Distribution Function")
lines(x,pf(x,1,1,2),col="green")
lines(x,pf(x,2,2,2),col="blue")
lines(x,pf(x,2,4,4),col="orange")
legend("topright",legend=paste("df1=",c(1,1,2,2),"df2=",c(1,1,2,4)," ncp=", c(0,2,2,4)), lwd=1, col=c("red", "green","blue","orange"))

set.seed(1)
S<-rf(1000,1,1,2)
ks.test(S, "pf", 1,1,2)   



set.seed(1)
x<-seq(-5,5,length.out=1000)
y<-dt(x,1,0)
plot(x,y,col="red",xlim=c(-5,5),ylim=c(0,0.5),type='l',xaxs="i", yaxs="i",ylab='density',xlab='',main="The T Density Distribution")
lines(x,dt(x,5,0),col="green")
lines(x,dt(x,5,2),col="blue")
lines(x,dt(x,50,4),col="orange")
legend("topleft",legend=paste("df=",c(1,5,5,50)," ncp=", c(0,0,2,4)), lwd=1, col=c("red", "green","blue","orange"))

set.seed(1)
x<-seq(-5,5,length.out=1000)
y<-pt(x,1,0)
plot(x,y,col="red",xlim=c(-5,5),ylim=c(0,0.5),type='l',xaxs="i", yaxs="i",ylab='F(x)',xlab='',main="The T Cumulative Distribution Function")
lines(x,pt(x,5,0),col="green")
lines(x,pt(x,5,2),col="blue")
lines(x,pt(x,50,4),col="orange")
legend("topleft",legend=paste("df=",c(1,5,5,50)," ncp=", c(0,0,2,4)), lwd=1, col=c("red", "green","blue","orange"))

set.seed(1)
S<-rt(1000, 1,2)
ks.test(S, "pt", 1, 2)   



set.seed(1)
x<-seq(-5,5,length.out=10000)
y<-dbeta(x,0.5,0.5)
plot(x,y,col="red",xlim=c(0,1),ylim=c(0,6),type='l',xaxs="i", yaxs="i",ylab='density',xlab='',main="The Beta Density Distribution")
lines(x,dbeta(x,5,1),col="green")
lines(x,dbeta(x,1,3),col="blue")
lines(x,dbeta(x,2,2),col="orange")
lines(x,dbeta(x,2,5),col="black")
legend("top",legend=paste("a=",c(.5,5,1,2,2)," b=", c(.5,1,3,2,5)), lwd=1,col=c("red", "green","blue","orange","black"))

set.seed(1)
x<-seq(-5,5,length.out=10000)
y<-pbeta(x,0.5,0.5)
plot(x,y,col="red",xlim=c(0,1),ylim=c(0,1),type='l',xaxs="i", yaxs="i",ylab='F(x)',xlab='',main="The Beta Cumulative Distribution Function")
lines(x,pbeta(x,5,1),col="green")
lines(x,pbeta(x,1,3),col="blue")
lines(x,pbeta(x,2,2),col="orange")
lines(x,pbeta(x,2,5),col="black")
legend("topleft",legend=paste("a=",c(.5,5,1,2,2)," b=", c(.5,1,3,2,5)), lwd=1,col=c("red", "green","blue","orange","black"))

set.seed(1)
S<-rbeta(1000,1,2)
ks.test(S, "pbeta",1,2)  



